#pragma once

#include <map>

#include "cugl.h"
#include "AntiGrav.h"
#include "Bipod.h"
#include "Cannon.h"
#include "Missiles.h"
#include "Nuclear.h"
#include "Electric_Brain.h"
#include "Phaser.h"
#include "Tracks.h"

#include "MissileMunition.h"
#include "CannonMunition.h"
#include "PhaserMunition.h"
#include "ParticleCollision.h"
#include "spotLight.h"

#include "Map.h"

class Robot
{
public:
	Robot(Map *);
	void display();
	void loadImageLife();
	bool deleteRobot();
	void setLocation(GLfloat, GLfloat, GLfloat);
	bool move(GLfloat, GLfloat, GLfloat);
	bool moveForward();
	bool moveBackward();
	void moveUp();
	void moveDown();
	void rotate(GLfloat);
	void addBipod();
	void addAntiGrav();
	void addTracks();
	void addCannon(int pos = 0);
	void addMissile(int pos = 0);
	void addNuclear(int pos = 0);
	void addEBrain(int pos = 0);
	void addPhaser(int pos = 0);
	void finished();
	GLfloat getX();
	GLfloat getY();
	GLfloat getZ();
	GLfloat getHeight();
	GLfloat getAngle();
	GLfloat* getLightPosition();
	GLfloat* getLightDirection();
	void rotateCameraLeft();
	void rotateCameraRight();
	void tiltUp();
	void tiltDown();
	void resetCamera();
	void fire();
	void fireMissiles();
	void fireCannon();
	void firePhaser();
	void animate();
	void switchTexture();
	void setID(int);
	int getID();
	void setMapRobots(std::map<int, Robot*>*);
	void damage(int);
	void random();
	bool isRandom();
	void turnLightOn();
	void turnLightOff();

	//void displayLife(std::vector<GLfloat>);
	void displayLife();
	~Robot(void);

	cugl::Camera *camera;
private:
	void addCamera();
	void refreshPositionCamera();
	void setBoundaries();
	
	int numberElements;
	int id;
	bool randomFlag;
	// timer to slow down the random robot
	int timerRandom;
	// position
	GLfloat x;
	GLfloat y;
	GLfloat z;
	// texture
	GLuint currentTexture;
	GLuint textureLife;
	// orientation of the robot in radians
	GLfloat angle;
	// orientation of the camera in radians
	GLfloat angleCam;
	GLfloat angleCamTilt;
	// height of the entire robot
	GLfloat height;
	// light
	GLfloat light_position[4];
	GLfloat light_direction[3];
	// damage
	bool destroyed;
	bool deleteO;

	// size of map
	GLfloat sizeX;
	GLfloat sizeZ;

	RobotPart *antigravUnit;
	RobotPart *bipod;
	RobotPart *cannon;
	RobotPart *missiles;
	RobotPart *nuclear;
	RobotPart *eBrain;
	RobotPart *phaser;
	RobotPart *tracks;
	Munition *missilesMunition;
	Munition *cannonMunition;
	Munition *phaserMunition;
	ParticleCollision *pc;

	RobotPart *vect[6];

	// map
	Map *map;

	// ID map to Robot pointer;
	std::map<int, Robot*> *mapRobots;

	float life;
	float maxLife;

	spotLight* robotLight;
};

